#! /usr/bin/perl -wl
#------------------------------------------------
# Author:    vj
# Created:   Tue Dec 25 11:23:49 IST 2012
# File Name: analyzer
# USAGE: 
#       analyzer 
# 
# 
#------------------------------------------------
my (@set, @acc, @fields, @cnt) = (0, 0, 0, 0);

while (<>) {
        chomp;
        next if not (/^\d+\s+:\s+C .. C#\d$/);

        @fields = split /\s+/;

        foreach my $n (0 .. 3) { if (/c -> c#$n/i) { $set[$n] = $fields[0] } }

        foreach my $n (0 .. 3) { if (/c <- c#$n/i) { $acc[$n] += $fields[0] - $set[$n]; $set[$n] = 0; $cnt[$n]++ } }
}

foreach (0 .. 3) { $acc[$_] += $fields[0] - $set[$_] }

foreach (0 .. 3) {
        printf "Core $_:\n";
        printf "\tNo of Transactions: %d\n", $cnt[$_];
        printf "\tAvg Number of cycles per transaction: %f\n", $acc[$_] / (10 * $cnt[$_]);
}
